-
Notifications
You must be signed in to change notification settings - Fork 0
Feature40/sub task #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Muhammadou1
commented
Nov 10, 2025
- User is able to create a task as a child task and link it to a ParentTaskId that already exists
- User is able to edit a task that has no parent and associate it to a ParentTaskId
- User is not able to mark a parent task as complete unless all its chid tasks are marked as complete
Web.Api/Dto/Request/TaskCreateDto.cs
Outdated
| public string Title { get; set; } | ||
| public DateTime? DueDate { get; set; } | ||
| public int Priority { get; set; } | ||
| public Guid ParentTaskId { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParentTaskId is optional.
Web.Api/Dto/Response/TaskDto.cs
Outdated
| public string Title { get; set; } | ||
| public DateTime? DueDate { get; set; } | ||
| public int Priority { get; set; } | ||
| public Guid ParentTaskId { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParentTaskId is optional.
| @@ -1 +1 @@ | |||
| using System; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert all changes to this file.
|
|
||
| namespace Web.Api.Persistence.Repositories | ||
| { | ||
| public class TaskItemRepo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert whitespace and new line changes in this file.
| if (taskCreatedDto.ParentTaskId != Guid.Empty) | ||
| { | ||
| SubTask subTask = new SubTask | ||
| { | ||
| TaskItemId = taskCreatedDto.ParentTaskId, | ||
| SubTaskItemId = taskCreation.Id, | ||
| CreatedDate = DateTime.Now, | ||
| CreatedUserId = userId | ||
| }; | ||
| taskCreation.SubTaskSubTaskItems.Add(subTask); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you move this before the first save changes call, you would not need to call save changes for a second time. refactor to so that it does a single call.
| Title = taskCreation.Title, | ||
| DueDate = taskCreation.DueDate, | ||
| Priority = taskCreation.Priority, | ||
| ParentTaskId = taskCreation.SubTaskSubTaskItems?.FirstOrDefault()?.TaskItemId ?? Guid.Empty, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correcting the properties on the dto would fix this assignment mess.
| Title = taskItem.Title, | ||
| DueDate = taskItem.DueDate, | ||
| Priority = taskItem.Priority, | ||
| ParentTaskId = taskItem.SubTaskSubTaskItems?.FirstOrDefault()?.TaskItemId ?? Guid.Empty, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correcting the Dto will fix this.
| } | ||
|
|
||
| // Prevent completing a parent task when any child sub-task is not complete. | ||
| if (taskItem.SubTaskTaskItems != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not going to work. You're not looking beyond the immediate child.
Additionally, because you can link tasks at any point in their lifetime, you can mix pending and completed tasks in any order.
(1 complete) -> (2 pending) -> (3 pending) -> (4 complete) -> (5 pending)
....................................................................................................................... \ -> (6 pending)
If this were to happen, we would still need to ensure that we close them in sequence. That means if you try to complete 3, it should deny the user until 5 and 6 are closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue we encountered has been fix. At any time where child task is found to be pending a parent task will not be allowed as complete
| /// <param name="taskId"></param> | ||
| /// <param name="userId"></param> | ||
| /// <returns></returns> | ||
| public async Task<TaskItem?> GetTaskByIdAsync(Guid taskId, Guid userId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isnt going to work, this is not a broad enough view of all the data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Especially with the recursive calls, because eventually the recursion will run out of data to process due to the original query.